﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyHealthOnline.Dal.Generated.CollectionClasses;
using MyHealthOnline.Business;

namespace MyHealthOnline.Patient
{
    public partial class ViewPatientConsultations : System.Web.UI.Page
    {
        public int PacientId
        {
            get
            {
                return Convert.ToInt32(Session["Id"]);
            }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                grdConsults.DataSource = ConsultBusiness.GetConsults();
                grdConsults.DataBind();
            }
        }

        protected void grdConsults_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int index = Convert.ToInt32(e.CommandArgument);
            if (e.CommandName == "Open")
            {
                int id = Convert.ToInt32(grdConsults.DataKeys[index].Value);
                Response.Redirect(string.Format("~/Patient/ViewConsult.aspx?ConsultId={0}", id));
            }
        }
    }
}